python f string decimal places

46

python f string decimal places -

>>> a = 10.1234
>>> f'{a:.2f}'
'10.12'

f string decimal places -

>>> a = 10.1234
>>> f'{a:.2f}'
'10.12'

python 2 decimal places format -

>>> foobar = 3.141592
>>> print(f'My number is {foobar:.2f} - look at the nice rounding!')

My number is 3.14 - look at the nice rounding!

python f string 2 decimals -

>>> number1 = 10.1234
>>> f'{number1:.2f}'
'10.12'

python 2 decimal places format -

print "%.2f" % 5

Comments

Submit
0 Comments